package com.avcdata.aoscustommade.activity;

import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.avcdata.aoscustommade.R;
import com.avcdata.aoscustommade.main.BaseActivity;
import com.avcdata.aoscustommade.utils.AppActivityManager;
import com.avcdata.aoscustommade.utils.AvcConstants;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;


/**
 * 忘记密码选择页
 */
public class ForgetPassword_Activity extends BaseActivity {

    @ViewInject(R.id.leftImage)
    private ImageView leftImage;
    @ViewInject(R.id.leftText)
    private TextView leftText;
    @ViewInject(R.id.title)
    private TextView title;
    @ViewInject(R.id.next_step)
    private Button next_step;
    @ViewInject(R.id.find_email_lay)
    private RelativeLayout find_email_lay;
    @ViewInject(R.id.find_phone_lay)
    private RelativeLayout find_phone_lay;
    @ViewInject(R.id.find_emailimg)
    private ImageView find_emailimg;
    @ViewInject(R.id.find_phoneimg)
    private ImageView find_phoneimg;

    private boolean type = true;//找回类型


    @Override
    public void initView() {
        setContentView(R.layout.activity_forgetpassword);
        AppActivityManager.getAppManager().addActivity(this);
        ViewUtils.inject(this);
    }

    @Override
    public void initInstall() {
        title.setText(getResources().getString(R.string.login_forgotpassword2));
        find_phoneimg.setImageResource(R.mipmap.selected);
    }

    @Override
    public void initData() {

    }

    @Override
    public void evenControl() {
        leftImage.setOnClickListener(this);
        leftText.setOnClickListener(this);
        next_step.setOnClickListener(this);
        find_email_lay.setOnClickListener(this);
        find_phone_lay.setOnClickListener(this);


    }

    @Override
    public void onClickEvent(View view) {
        switch (view.getId()) {
            case R.id.leftImage:
            case R.id.leftText:
                AppActivityManager.getAppManager().finishActivity(this);
                break;
            case R.id.find_email_lay:
                if (type) {
                    find_emailimg.setImageResource(R.mipmap.selected);
                    find_phoneimg.setImageResource(R.mipmap.select);
                    type = false;
                }
                break;
            case R.id.find_phone_lay:
                if (!type) {
                    find_emailimg.setImageResource(R.mipmap.select);
                    find_phoneimg.setImageResource(R.mipmap.selected);
                    type = true;
                }
                break;
            case R.id.next_step:
                Intent intent = new Intent(this, ForgetFindOrChangePassword_Activity.class);
                if (type) {
                    intent.putExtra(AvcConstants.PASSWORDCHANGE, "phone");
                } else {
                    intent.putExtra(AvcConstants.PASSWORDCHANGE, "email");
                }
                intent.putExtra("isLogin",true);
                startActivityForResult(intent,1);
                break;
        }

    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 1 && resultCode == 1){
            setResult(1);
            AppActivityManager.getAppManager().finishActivity(this);
        }

    }
}
